program fft_test
	
	use MKL_DFTI
	
	implicit NONE
	
	integer(4), parameter						:: LX = 4

	type(DFTI_DESCRIPTOR), pointer				:: MD_Handle
	complex, allocatable						:: zin(:)
	complex, allocatable						:: zout(:)
	
	integer(4)									:: sz(2)
	integer(4)									:: stt
	
	allocate( zin(LX*LX), zout(LX*LX), stat = stt)
	
	sz(1) = LX
	sz(2) = LX
	
	zin = 1
	
	stt = DftiCreateDescriptor( MD_Handle, DFTI_SINGLE, DFTI_COMPLEX, 2, sz)
!	stt = DftiSetValue( MD_Handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE)
	stt = DftiSetValue( MD_Handle, DFTI_PLACEMENT, DFTI_INPLACE)
	stt = DftiCommitDescriptor( MD_Handle)
	
!	stt = DftiComputeForward( MD_Handle, zin, zout)
	stt = DftiComputeForward( MD_Handle, zin)
	
	stt = DftiFreeDescriptor( MD_Handle)
	deallocate( zin, zout)
	
end program fft_test
	
!subroutine fft_wrap( n1, n2, xin, xout, dir)
!	! Variables
!	implicit NONE
!	integer(4), intent(IN)			:: n1
!	integer(4), intent(IN)			:: n2
!	complex, intent(IN)				:: xin(n1,n2)
!	complex, intent(OUT)			:: xout(n1,n2)
!	logical, intent(IN)				:: dir
!!-----------------------------------------------------------
!	integer(4), automatic						:: lm(2)
!	type(DFTI_DESCRIPTOR), pointer, automatic	:: MD_Handle
!	complex, allocatable, automatic				:: zin(:)
!	complex, allocatable, automatic				:: zout(:)
!	integer(4), automatic						:: stt
!	integer(4), automatic						:: i1, i2
!	
!	! Body of fft_wrap1
!	
!	allocate( zin(n1*n2), zout(n1*n2), stat = stt)
!	if ( stt /= 0) return
!	
!	lm(1) = n1
!	lm(2) = n2
!	
!	do i2 = 1, n2
!		zin( (i2-1)*n1+1:i2*n1) = xin( 1:n1, i2)
!	end do
!
!	stt = DftiCreateDescriptor( MD_Handle, DFTI_SINGLE, DFTI_COMPLEX, 2, lm)
!	stt = DftiSetValue( MD_Handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE)
!	stt = DftiCommitDescriptor( MD_Handle)
!	
!	if ( dir) then	
!		stt = DftiComputeForward( MD_Handle, zin, zout)
!	else
!		stt = DftiComputeBackward( MD_Handle, zin, zout)
!	end if
!	
!	stt = DftiFreeDescriptor( MD_Handle)
!	
!	do i2 = 1, n2
!		xout( 1:n1, i2) = zout( (i2-1)*n1+1:i2*n1)
!	end do
!
!	deallocate( zin, zout)
!	
!end subroutine fft_wrap
